<?php

namespace app\admin\controller;

class Branch extends  Base
{
    /**
     * @return mixed列表页
     */
    public function index()
    {
        $locations=model('BisLocation')->getBranchLocationByStatus(1);
        return $this->fetch('',['locations'=>$locations]);
    }

    public function apply()
    {
        $locations=model('BisLocation')->getBranchLocationByStatus();
        return $this->fetch('',['locations'=>$locations]);
    }

    public function detail($id)
    {
        $location=model('BisLocation')->get($id);
        //获取一级城市的数据
        $citys = model('City')->getNormalCitysByParentId();
        //获取一级栏目的数据
        $categorys = model('Category')->getNormalCategoryByParentId();
        $secategorys = model('Category')->getNormalCategoryByParentId($location['category_id']);
        $catchecked=getCategoryByPath($location['category_path']);
        return $this->fetch('',[
            'location'=>$location,
            'citys' => $citys,
            'categorys' => $categorys,
            'secategorys' => $secategorys,
            'catchecked' => $catchecked]);
    }

    public function nolist()
    {
        $locations=model('BisLocation')->getBranchLocationByStatus(2);
        return $this->fetch('',['locations'=>$locations]);
    }

    public function delist()
    {
        $locations=model('BisLocation')->getBranchLocationByStatus(-1);
        return $this->fetch('',['locations'=>$locations]);
    }
}